/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Test;

/**
 *
 * @author TauPo
 */
import cms.dataaccess.ConferenceDAO;
import cms.dataaccess.DAOFactory;
import dto.Conference;
import dto.Confitemorder;
import dto.ConfitemorderId;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
public class TestDAO {
 
    
    public static void main(String agrv[]) throws ParseException{
          DAOFactory df = DAOFactory.getInstance();
          ConferenceDAO conDAO=  df.getConferenceDAO();
          System.out.println("Testing getALLConference start");
          List<Conference> confList=conDAO.getAllConference();
         
          for(int i=0; i<conDAO.getAllConference().size();i++){
              System.out.println("ConferenceName:"+conDAO.getAllConference().get(i).getConferenceName());
          }
          System.out.println("Testing getALLConference End");
          
            
            ConfitemorderId orderid =  new ConfitemorderId("Mobile App Dev","ios book","ABC");
             
            
            
            DateFormat formatter =new SimpleDateFormat("yyyy/mm/dd hh:mm:ss");
            java.util.Date dt = new java.util.Date();
            String currentTime = formatter.format(dt);
            Date regDate = formatter.parse(currentTime);
            
            Confitemorder  itemOrder = new Confitemorder(orderid,2.0,1,regDate);
            
             DAOFactory.getInstance().getConferenceItemOrderDAO().updateConfitemorder(itemOrder);
          
       /*   System.out.println("Testing getConferenceByName start");
          Conference conf =  df.getConferenceDAO().getConferenceByName("EnviromentDiscuss");
          System.out.println("EventDetail:"+conf.getEventDetail());
          System.out.println("Testing getConferenceByName End");
          
          
          System.out.println("Testing saveUpdateConfernce start ");
           String name = "Enviroment Janpan11";
           String eventDetail = "To dicuss the jap enviroment11";
           String location = "Janpan11";
           boolean callForPaper = false;
           Date submitDate = new Date();
           boolean notifyResults = false;
           double price = 23.0;
        
          Conference conf1 = new Conference(name, eventDetail, location, callForPaper, submitDate, notifyResults, price,0) ;
        
          System.out.println("saveUpdateConfernce  by Confernce object start"); 
         
          ConferenceDAO instance = new ConferenceDAOImpl();
          instance.saveUpdateConfernce("Enviroment Janpan10", eventDetail+"10", location, callForPaper, submitDate, notifyResults, price);
      
          int bsize=instance.getAllConference().size();
          instance.saveUpdateConfernce(conf1);
          // TODO review the generated test code and remove the default call to fail.
          int asize = instance.getAllConference().size();
          if(asize == bsize+1) {
            System.err.println("Confernce object save to database succesfully");
          }
         System.out.println("saveUpdateConfernce  by Confernce object End");
          */
    }
}
